//
//  DLBaseNavController.m
//  delongzhitou
//
//  Created by Mr.Wang on 2018/11/22.
//  Copyright © 2018 delongzhitou. All rights reserved.
//

#import "DLBaseNavController.h"

@implementation DLBaseNavController


- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.navigationBar.tintColor = [UIColor whiteColor];
    self.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName : [UIColor whiteColor]};
    self.navigationBar.barTintColor = kColorRGB(65, 163, 145);
    
}

- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated {
    // 如果现在push的不是栈底控制器(最先push进来的那个控制器)
    if (self.viewControllers.count) {
        viewController.hidesBottomBarWhenPushed = YES;
    }
    [super pushViewController:viewController animated:animated];
    
    UIButton *backButton = [UIButton buttonWithType:0];
    backButton.frame = CGRectMake(0, 0, 25, 25);
    [backButton setImage:[UIImage imageNamed:@"nav_back_black"] forState:UIControlStateNormal];
    [backButton addTarget:self action:@selector(dismiss) forControlEvents:UIControlEventTouchUpInside];
    viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:backButton];
}

- (void) dismiss{
    
    [self dismissViewControllerAnimated:YES completion:^{
        
        if (kuserManager.isTokenAvailable == NO) {
            
            kuserManager.lastVc.tabBarController.selectedIndex = 0;
        }
    }];
}

@end
